import { _decorator, Component, Node } from 'cc';
import AbstractComponent from '../../base/AbstractComponent';
import { Label } from 'cc';
import { MultiMsgMgr } from './MultiMsgMgr';
import { showErrorTip } from '../../tools/PopuUp';
import UtilTool from '../../tools/UtilTool';
const { ccclass, property } = _decorator;

/**
 * 是否参赛弹出框
 */
@ccclass('JoinTipWnd')
export class JoinTipWnd extends AbstractComponent {

    @property(Label)
    label_reward : Label = null; // 奖励

    data = null

    start() {

    }

    initData(data) {
        this.data = data

        this.label_reward.string = data
    }

    update(deltaTime: number) {
        
    }

    // 确定参赛
    onBtnJoin() {
        MultiMsgMgr.getInstance().sendJoin()
        .then((data) => {
            UtilTool.printLog("test join room", data);
            
            if(data.result == 0) {
                this.node.destroy()
            } else {
                showErrorTip(data.result)
                this.node.destroy()
            }

        })
    }

}

